Skip to content

[GLUTEN-12468][FLINK] Handle WatermarkStatus elements in GlutenSourceFunction#12461

Open
lgbo-ustc wants to merge 17 commits into
apache:mainfrom
bigo-sg:feature/idle-source-handling
Open

[GLUTEN-12468][FLINK] Handle WatermarkStatus elements in GlutenSourceFunction#12461
lgbo-ustc wants to merge 17 commits into
apache:mainfrom
bigo-sg:feature/idle-source-handling

Conversation

@lgbo-ustc

@lgbo-ustc lgbo-ustc commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Add processing for WatermarkStatus elements from native idle detection. When IDLE is received, call sourceContext.markAsTemporarilyIdle() to notify Flink that this source is temporarily idle, allowing watermark progress to continue from other sources.

Related PRs:

closed: #12468

How was this patch tested?

UTs

Was this patch authored or co-authored using generative AI tooling?

Generated-by: deepseek v4 pro

@lgbo-ustc lgbo-ustc changed the title [WIP][FLINK] Handle WatermarkStatus elements in GlutenSourceFunction [GLUTEN-12468][FLINK] Handle WatermarkStatus elements in GlutenSourceFunction Jul 7, 2026
@lgbo-ustc lgbo-ustc marked this pull request as ready for review July 7, 2026 09:11
@lgbo-ustc lgbo-ustc requested a review from KevinyhZou July 7, 2026 09:28
Add processing for WatermarkStatus elements from native idle detection.
When IDLE is received, call sourceContext.markAsTemporarilyIdle() to notify
Flink that this source is temporarily idle, allowing watermark progress to
continue from other sources.
Adds GlutenSourceFunctionWatermarkStatusTest with 5 test cases covering:
- IDLE status triggers markAsTemporarilyIdle()
- ACTIVE status is a no-op on SourceContext
- IDLE→ACTIVE transition does not call markAsTemporarilyIdle()
- Repeated IDLE calls are idempotent
- ACTIVE status produces no invocations

Uses reflection to invoke private processWatermarkStatus() and a custom
TrackingSourceContext spy — no Mockito or native session required.
…uster

- Add GlutenStreamSource.isShouldCallNoMoreSplits() delegating to source
- Add GlutenSourceFunction.isShouldCallNoMoreSplits() getter
- Extend OffloadedJobGraphGenerator to preserve shouldCallNoMoreSplits
  when creating a new GlutenSourceFunction during offloading
- Rewrite GlutenSourceFunctionWatermarkStatusE2ETest as a real E2E test
  using embedded Kafka broker + Flink MiniCluster, verifying that
  WatermarkStatus.IDLE is emitted after idle timeout
- Fix EmptyNode output type in WatermarkPushDownSpec project to match
  table scan schema (avoids FieldNotFound error during plan init)
Covered by GlutenSourceFunctionWatermarkStatusE2ETest which tests
the same behavior end-to-end with Kafka + MiniCluster.
Add testIdleInputExcludedFromMinWatermark to
GlutenStreamTwoInputWatermarkStatusTest: when one input is marked
IDLE, its watermark is excluded from min-watermark calculation so
the other active input can advance freely.
@lgbo-ustc lgbo-ustc force-pushed the feature/idle-source-handling branch from 3342506 to 9cd1b66 Compare July 13, 2026 02:13

@KevinyhZou KevinyhZou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion on API surface: please tighten shouldCallNoMoreSplits so it stays a test/unbounded-split concern rather than a public production toggle (details in the inline comment on GlutenSourceFunction).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please tighten / 收敛 shouldCallNoMoreSplits

This flag is introduced mainly so the idle E2E test can keep the native task alive (skip task.noMoreSplits(id) after the initial split). That need is valid, but the current shape turns a test knob into a public production API:

public void setShouldCallNoMoreSplits(boolean value) { ... }
public boolean isShouldCallNoMoreSplits() { ... }

and it is also propagated through OffloadedJobGraphGenerator / GlutenStreamSource.

Risks:

  1. Accidental false in production changes split lifecycle semantics.
  2. Offload path now has to carry a UT-oriented toggle as a first-class field.
  3. Naming/setter surface suggests general configuration, but docs say it is for “unbounded streaming test scenarios”.

Suggestions (any one is fine):

  • Prefer a constructor param or package-private / @VisibleForTesting API instead of a public setter.
  • Avoid wiring this through OffloadedJobGraphGenerator unless production offload truly needs a non-default value (default should stay true).
  • Longer term: derive from connector/split boundedness (unbounded Kafka → don’t auto noMoreSplits) rather than a hand-set boolean.

Functionality can stay; please just shrink visibility and keep it out of the general runtime surface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FLINK] Implement idle source handling for watermark status propagation

2 participants